package com.autism.app;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.bumptech.glide.Glide;

public class SecondFragment extends Fragment {
    private ImageView imgCover;
    private Button button;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_second, container,false);

        //加载图片
        imgCover = view.findViewById(R.id.imageView8);
        String url = "https://cn.yadingtour.com/templates/rt_supra/custom/images/2019_11/2019110601.jpg";
        Glide.with(this).load(url).into(imgCover);

        //设置点击监听，通过Intent打开浏览器
        button = view.findViewById(R.id.button);
        button.setOnClickListener(v -> {
            Uri uri = Uri.parse("http://www.yadingtour.com/book/providerIndex.action?iscenicid=1");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        });
        return view;
    }
}